<?php

use console\db\channels\TransferTableMigration;

/**
 * 用户收件地址转移
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class m300000_000015_t_user_address extends TransferTableMigration {

    /**
     * @inheritdoc
     */
    public $sourceDb = 'olddb';

    /**
     * @inheritdoc
     */
    public function getTransferOptions() {
        return [
            'table' => [
                'user_address' => 'member_addresses',
            ],
            'columns' => [
                'id',
                'user_id' => 'uid',
                'name',
                'mobile' => function($data) {
                    if (!is_numeric($data['phone']) || strlen($data['phone']) > 11) {
                        return '';
                    }
                    return $data['phone'];
                },
                'province',
                'city',
                'district',
                'address_detail' => 'address',
                'is_default' => 'default',
                'area_code' => function() {
                    return 0;
                },
                'postal_code' => function() {
                    return 0;
                },
                'created_at' => 'inputtime',
                'updated_at' => 'updatetime',
            ],
        ];
    }

}
